﻿using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Views.Grid;
using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Const;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client.Base
{
    public partial class Base_ExamPlace_List : BaseForm
    {
        ServiceBase service = new ServiceBase();
        ServiceComm bllCommService = new ServiceComm();
      
        public Base_ExamPlace_List()
        {
            InitializeComponent();
            BindCity();
            BindData();
        }
        #region 加载考点省份
        void BindCity()
        {
            cmbKD.Properties.NullText = "";
            this.cmbKD.Properties.Columns.Add(new LookUpColumnInfo("DicNO", "省份代码"));
            this.cmbKD.Properties.Columns.Add(new LookUpColumnInfo("DicName", "省份名称"));
            this.cmbKD.Properties.DataSource = bllCommService.GetDicDataTableByDicTableName("TB_Dic_ExamProvince");
            this.cmbKD.Properties.DisplayMember = "DicName";
            this.cmbKD.Properties.ValueMember = "DicNO";
        }
        #endregion
        private void BindData()
        {

            string KD = string.Empty;
            if (cmbKD.Text == "" || cmbKD.EditValue == null || cmbKD.EditValue.ToSafeString().Length == 0)
            {
            }
            else
            {
                KD = cmbKD.EditValue.ToSafeString();
            }
            using (DataTable dt = service.GetSysExamPlaceDataTable(KD.ToSafeString(), txtName.Text.ToSafeString(), string.Empty))
            {
                this.gridControl1.DataSource = dt;
            }
        }
        private void benQuery_Click(object sender, EventArgs e)
        {
            BindData();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            Base_ExamPlace_Option option = new Base_ExamPlace_Option(string.Empty);
            if (option.ShowDialog() == DialogResult.OK)
            {
                this.BindData();
            }
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            GridView rows = sender as GridView;
            int[] inteurm = rows.GetSelectedRows();
            if (inteurm != null && inteurm.Length > 0)
            {
                string strExamPlaceNO = rows.Rows[inteurm[0]].DataRow["ExamPlaceNO"].ToSafeString();
                Base_ExamPlace_Option option = new Base_ExamPlace_Option(strExamPlaceNO);
                if (option.ShowDialog() == DialogResult.OK)
                {
                    this.BindData();
                }
            }
        }
    }
}
